<!--------------------------------------------------------------------------->
<!--                        IGNORE THIS SECTION                            --><html><head>
		<title>IPC using VB.NET an FileMapping</title>
		<STYLE> BODY, P, TD { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt }
	H2,H3,H4,H5 { color: #ff9900; font-weight: bold; }
	H2 { font-size: 13pt; }
	H3 { font-size: 12pt; }
	H4 { font-size: 10pt; color: black; }
	PRE { BACKGROUND-COLOR: #FBEDBB; FONT-FAMILY: "Courier New", Courier, mono; WHITE-SPACE: pre; }
	CODE { COLOR: #990000; FONT-FAMILY: "Courier New", Courier, mono; }
	</STYLE>
		<link href="http://www.codeproject.com/styles/global.css" type="text/css" rel="stylesheet"></head>
	<body bgColor="#ffffff" color="#000000">
		<!--------------------------------------------------------------------------->
		<!-------------------------------     STEP 1      --------------------------->
		<!--  Fill in the details (CodeProject will reformat this section for you) --><pre>Title:       Using FileMapping for IPC with VB.NET
Author:      Alberto Alday 
Email:       c020339@hotmail.com<A href="mailto:aalday@Environment">
Environment</A>            
        
       
: VB.NET
Keywords:    FileMapping, IPC,<BR>Level:       Intermediate
Description: An article on something-or-other
Section      Miscellaneous
SubSection   General
</pre>
		<!-------------------------------     STEP 2      --------------------------->
		<!--  Include download and sample image information.                       -->
		<UL class="download">
			<li>
				<A href="MemMap.zip">Download demo project - 100 Kb </A>
			</li>
		</UL>
		<!-------------------------------     STEP 3      --------------------------->
		<!--  Add the article text. Please use simple formatting (<h2>, <p> etc)   -->
		<h2>Introduction</h2>
		<p>.NET inter-process mechanisms are very slow. With some system calls it's easy to 
			use file mapping, and that's&nbsp;the faster mechanism for IPC
			<h2>Classes</h2>
		<P>MemMap.
		</P>
		<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
			<P>This class encapsulate a file mapping zone with system page-file support. All 
				you need is to give a name and a size.</P>
			<P>Usage:</P>
			<PRE><P>Process 1</P><P>dim mem1 as MemMap=new MemMap("ZONE1",2048)<BR>mem1.writeString(0,"String to share")</P><P>Process 2</P><P>dim mem1 as MemMap=new MemMap("ZONE1",2048)<BR>dim sharedString=mem1.readString(0)</P><P>&nbsp;</P><P>mem1.close() at the end of both programs</P></PRE>
			<P>This class handles creation or reuse of the fileMapping within the&nbsp;"new" 
				method, and has methods&nbsp;for reading a writing Integers and strings given 
				an offset.</P>
		</BLOCKQUOTE>
		<P dir="ltr">MemChannel</P>
		<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
			<P dir="ltr">This class use&nbsp;MemMap class to implement a FIFO queue of strings. 
				You can create&nbsp;any number of channels simply giving diferent names to each 
				one.</P>
			<P dir="ltr">Usage:</P>
			<pre><P>Process1</P><P>dim cha1 as MemChannel=new MemChannel("CHANAME1")<BR>cha1.putMsg("This is the message")</P><P>Process2</P><P>dim cha1 as MemChannel=new MemChannel("CHANAME1")<BR>msgbox cha1.getMsg()</P><P>&nbsp;</P><P>cha1.close() at the end of both programs<BR></P></pre>
		</BLOCKQUOTE>
		<P dir="ltr"><BR>
			MServer.exe</P>
		<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
			<P dir="ltr">Example of server reading from a channel</P>
		</BLOCKQUOTE>
		<P dir="ltr">Client.exe</P>
		<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
			<P dir="ltr">Example of client writing to une channel&nbsp;</P>
		</BLOCKQUOTE>
		<h2>Points of Interest</h2>
		<p>
		The sample programs included run at 50.000 msg per second on a PIV 3 GHz. But 
		realy they block's each other while accesing the channel an CPU is not 100% 
		busy.
		<P>
			With MemMap class support it's easy to implement other IPC mechanisms as shared 
			Dictionarys.
			<h2>History</h2>
		<p>
			First version 25-06-2005</p>
	</body>
</html>
